/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 救援员工服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const rescueEmployeeApi = urls.rescueEmployee

function listAllRescueDriver(companyId, success, complete) {
  postRequest(rescueEmployeeApi.listAllRescueDriver + companyId, {}, {}, success, complete)
}

function listGroupRescueEmployee(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listGroupRescueEmployee + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listCompanyPayables(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listCompanyPayables + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listDriverPayables(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listDriverPayables + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listManager(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listManager + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listOperationDriver(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listOperationDriver + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listAuditDriver(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listAuditDriver + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listDriver(param, page, pageSize, success, complete) {
  postRequest(rescueEmployeeApi.listDriver + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function updateRescueCompanyManager(param, success, complete) {
  postRequest(rescueEmployeeApi.updateRescueCompanyManager, {}, param, success, complete)
}

function auditRescueCompanyManager(id, param, success, complete) {
  postRequest(rescueEmployeeApi.auditRescueCompanyManager + id, {}, param, success, complete)
}

function auditRescueCompanyDriver(id, param, success, complete) {
  postRequest(rescueEmployeeApi.auditRescueCompanyDriver + id, {}, param, success, complete)
}

function againApplyRescueCompanyDriver(id, status, success, complete) {
  postRequest(rescueEmployeeApi.againApplyRescueCompanyDriver + id + '/' + status, {}, {}, success, complete)
}

function getRescueEmployeeById(id, success, complete) {
  getRequest(rescueEmployeeApi.getRescueEmployeeById + id, {}, success, complete)
}

function unfreezeCommission(param, success, complete) {
  postRequest(rescueEmployeeApi.unfreezeCommission, {}, param, success, complete)
}

function adjustmentCommission(param, success, complete) {
  postRequest(rescueEmployeeApi.adjustmentCommission, {}, param, success, complete)
}

function adjustmentIntegral(param, success, complete) {
  postRequest(rescueEmployeeApi.adjustmentIntegral, {}, param, success, complete)
}

function countAuditingRescueCompanyManager(success, complete) {
  getRequest(rescueEmployeeApi.countAuditingRescueCompanyManager, {}, success, complete)
}

function countAuditingRescueCompanyDriver(success, complete) {
  getRequest(rescueEmployeeApi.countAuditingRescueCompanyDriver, {}, success, complete)
}

function countRescueCompanyEmployee(employeeRole, success, complete) {
  getRequest(rescueEmployeeApi.countRescueCompanyEmployee, {employeeRole: employeeRole,searchType: ''}, success, complete)
}

function countTotalRescueCompanyEmployee(employeeRole, success, complete) {
  getRequest(rescueEmployeeApi.countRescueCompanyEmployee, {employeeRole: employeeRole,searchType: 'total'}, success, complete)
}

function removeRescueEmployee(ids, success, complete) {
  postRequest(rescueEmployeeApi.removeRescueEmployee, {}, ids, success, complete)
}

function deleteSingleRescueEmployee(id, success, complete) {
  let ids = []
  ids.push(id)
  removeRescueEmployee(ids, success, complete)
}

export default {
  countAuditingRescueCompanyManager,
  countAuditingRescueCompanyDriver,
  listAllRescueDriver,
  listGroupRescueEmployee,
  listCompanyPayables,
  listDriverPayables,
  listManager,
  listOperationDriver,
  listAuditDriver,
  listDriver,
  updateRescueCompanyManager,
  auditRescueCompanyManager,
  auditRescueCompanyDriver,
  getRescueEmployeeById,
  removeRescueEmployee,
  deleteSingleRescueEmployee,
  countRescueCompanyEmployee,
  countTotalRescueCompanyEmployee,
  unfreezeCommission,
  adjustmentCommission,
  adjustmentIntegral,
  againApplyRescueCompanyDriver
}
